package com.ftg.learn.bus.userole_control.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ftg.learn.bus.userole_control.pojo.userole_control;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface userole_control_mapper extends BaseMapper<userole_control> {

    @Select("select uc.userole_id,uc.user_id,uc.role_id,role.role_name from userole_control uc " +
            "left join role on uc.role_id=role.role_id " +
            "where uc.user_id=#{user_id}")
    List<Map<String, Object>> queryRoleForUserByUsername(String user_id);

    @Insert("insert into userole_control(userole_id,user_id,role_id) values (#{userole_id},#{user_id},#{role_id})")
    int insert(userole_control userole_control);

    @Delete("delete from userole_control where user_id=#{user_id}")
    int deleteByUser_id();


}
